package gintest

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Router() *gin.Engine {
	router = gin.Default()
	router.GET("/get", func(c *gin.Context) {
		name, _ := c.GetQuery("name")
		c.String(http.StatusOK, "get:"+name)
	})
	router.POST("/post", func(c *gin.Context) {
		name, _ := c.GetPostForm("name")
		c.String(http.StatusOK, "post:"+name)

	})
	return router
}

var router *gin.Engine

func GinHttpServer() {
	router = Router()
	router.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
